EnemyMove=class("EnemyMove");






function EnemyMove:ctor(speed)
    self.enemyType = 0;
    self.lateTime=2;
    self.Hp=2;
    self.gameObject=newObject(ThunderManager.prefabs[3]);
    self.transform=self.gameObject.transform;
    self.transform.position=Vector3(math.random( -2.3,2.3),5.5 ,-9);
    
    self.firePos=self.transform:Find("firePos");
    self.rigid = self.gameObject:GetComponent('Rigidbody2D');
    self.rigid.velocity = Vector3.down*speed;
    self.luaTrigger = self.gameObject:AddComponent(typeof(LuaRigidTrigger));
    self.luaTrigger:AddHandler(self.OnTriggerEnter2D,self);
    --self:Enter();
    --UpdateBeat.Add(self.Update,self);
    UpdateBeat:Add(self.Update,self);
end
function EnemyMove:Update()
    
    self:ChickFire();
end
function EnemyMove:ChickFire()
    self.lateTime=Time.deltaTime+self.lateTime;
    if(self.lateTime>2)then
        self.lateTime=0;
    
        EnemyBulletMove.new(self.firePos,10,6);
    end
end

function EnemyMove:OnTriggerEnter2D(collider)
    if(collider.tag=="Player")then
        PlayerMove.Hurt();
    end
    if(collider.tag=="PlayerBullet")then
        self.Hp=self.Hp-1;
        if (self.Hp==0) then
            UpdateBeat:Remove(self.Update,self);
            destroy(self.gameObject);
            ThunderManager.ScoreAdd(1)
        end
        
    end
end
